package com.cy.pj.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 序列化和反序列化(I/O)
 * 1)序列化：将对象转换为字节的过程
 * 2)反序列化：将字节转换为对象的过程
 *
 */
@Data
@NoArgsConstructor
public class JsonResult implements Serializable {
    /*
     * 序列化，反序列化时的唯一标识
     * 当类的结构发生变化时，只要serialVersionUID不变，JVM底层都认为它是同一个类
     */
    private static final long serialVersionUID = 1018010862839495031L;
    private  Integer state = 1;
    private String message = "ok";
    private Object data;

    public JsonResult(String message) {
        this.message = message;
    }

    public JsonResult(Object data) {
        this.data = data;
    }

    public JsonResult(Throwable t) {
        this.state = 0;
        this.message = t.getMessage();
    }
}
